import { createStore } from "vuex";

export default createStore({
  state: {
    isUpload: false,
    DS: {},
    objectType: 0, // 分析对象： 0-我方，1-敌方
  },
  getters: {
    getBaseData(state) {
      return Object.keys(state.DS).length ? state.DS["base"][!state.objectType ? "our" : "enemy"] : [];
    },
    getAllocationData(state) {
      return Object.keys(state.DS).length ? state.DS["allocation"][!state.objectType ? "our" : "enemy"] : [];
    },
    getOverviewData(state) {
      return Object.keys(state.DS).length ? state.DS["overview"][!state.objectType ? "our" : "enemy"] : [];
    },
    getDatas(state) {
      return Object.keys(state.DS).length ? state.DS["datas"][!state.objectType ? "our" : "enemy"] : [];
    },
    getGroupDatas(state) {
      return Object.keys(state.DS).length ? state.DS["groupDatas"][!state.objectType ? "our" : "enemy"] : [];
    },
  },
  mutations: {
    loadDatas(state, datas) {
      state.isUpload = true;
      state.DS = datas;
    },
    clearDatas(state) {
      state.isUpload = false;
      state.DS = {};
    },
    setObjectType(state, type) {
      state.objectType = type;
    },
  },
  actions: {},
  modules: {},
});
